import React from 'react';
import { Form, Button, Input } from 'antd';
import { publish } from '../../api/news';
import { useAuth } from '../../context/AuthProvider';

const { TextArea } = Input;

const Upload = () => {
  const { user } = useAuth();
  
  const onFinish = (values) => {
    let data = {...values,draftUser:user.userId}

    publish(data).then(res => {
      console.log(res)
    })
  }

  return (
    <Form onFinish={onFinish}>
      <Form.Item name='draftTitle'>
        <Input placeholder="请输入标题..." style={{width:'500px'}} />
      </Form.Item>

      <Form.Item name='draftContext'>
        <TextArea rows={4} placeholder="请输入内容..." style={{width:'500px'}} />
      </Form.Item>

      <Form.Item>
        <Button type='primary' htmlType="submit" style={{marginTop:'20px'}}  >发布</Button>
      </Form.Item>
    </Form>
  )
}

export default Upload